package WaiBao;

import java.util.Arrays;

public class HeJiaHong {
    public static void main(String[] args) {
        String[] name = {"李贤达(班长)","李金轩(宣传委员)", "小李(学习委员)","张云清(生活委员)", "李忠义", "张雨涵", "李杰雄", "李克伟", "李豪杰", "张金一", "李藏难", "张博源",
                "李长难", "张贤达", "李聪同", "李欣柔", "张海安", "李冰洁", "张子崔", "王大陆", "李旭旭", "张荣村", "李松岭", "韩灵梦", "张一言", "李江山", "李胜义", "李强值",
                "林泽君", "何佳红(学生)"};//考生本人: 何佳红(学生)
        int[] age = {18,21,21,20, 18,21, 19, 20, 19, 19, 18, 18, 18, 20, 18, 19, 20, 19, 18, 19, 19, 19, 20, 19, 20, 21, 21,20, 20, 20};//最后一位：考生年龄:20

        double[] ruxuan1 = {80, 90, 86, 78, 78, 67, 78, 89, 81, 84, 91, 81, 85, 76, 64, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 87, 76, 87, 94};
        double[] ruxuan2 = {86, 84, 77, 94, 78, 77, 84, 74, 88, 72, 85, 94, 72, 87, 64, 75, 76, 90, 66, 98, 72, 71, 95, 86, 78, 81, 84, 84, 81, 95};
        double[] ruxuan3 = {87, 77, 83, 85, 75, 69, 78, 69, 84, 88, 83, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 82, 78, 79, 87, 96};


        double pen1;//代表每个学生的总分
        double pen2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            pen1 =ruxuan1[i] + ruxuan2[i] + ruxuan3[i];
//            pen2= (pen1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + pen1);
//            System.out.println(name[i] + "的平均分为:" +pen2);
//        }


        double hundun1 = 0,hundun2 = 0;
        double[] yuntun = new double[30];
//        for (int i = 0; i < 30; i++) {
//            hundun1=ruxuan1[i] +ruxuan2[i] + ruxuan3[i];
//            hundun2 = (hundun1* 1.0) / 3;
//            yuntun[i] = hundun2;
//        }
//
//        for (int i = 0; i < yuntun.length - 1; i++) {
//            for (int j = 0; j <yuntun.length - i - 1; j++) {
//                if (yuntun[j] <yuntun[j + 1]) {
//                    double tep = yuntun[j];
//                    yuntun[j] =yuntun[j + 1];
//                    yuntun[j + 1] = tep;
//                }
//            }
//        }
//
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(yuntun[i]);
//        }



        double diao1 = 0, diao2 = 0, diao3 = 0;//计算每门课的平均分
        double lankou1 = 0,  lankou2 = 0,lankou3 = 0;//计算每门课标准差
        double sktwo1 = 0,sktwo2 = 0, sktwo3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < ruxuan1.length; i++) {
            he += ruxuan1[i];
        }
        diao1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +diao1);
        double Sum = 0;
        for (int i = 0; i < ruxuan2.length; i++) {
            Sum += ruxuan2[i];
        }
        diao2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" +diao2);
        double sum = 0;
        for (int i = 0; i <ruxuan3.length; i++) {
            sum +=ruxuan3[i];
        }
        diao3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + diao3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < ruxuan1.length; i++) {
            c1 += (ruxuan1[i] - diao1) * (ruxuan1[i] -diao1);
        }
        lankou1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" +lankou1);
        for (int i = 0; i <ruxuan2.length; i++) {
            c2 += (ruxuan2[i] -diao2) * (ruxuan2[i] -diao2);
        }
        lankou2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +lankou2);

        for (int i = 0; i <ruxuan3.length; i++) {
            c3 += (ruxuan3[i] - diao3) * (ruxuan3[i] - diao3);
        }
        lankou3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +lankou3);
//////////
//        Arrays.sort(ruxuan1);
//        Arrays.sort(ruxuan2);
//        Arrays.sort(ruxuan3);
//        sktwo1 = (ruxuan1[15] + ruxuan1[14]) * 1.0 / 2;
//        sktwo2 = (ruxuan2[15] +ruxuan2[14]) * 1.0 / 2;
//        sktwo3 = (ruxuan3[15] +ruxuan3[14]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" + sktwo1);
//        System.out.println("农业设施设计与制造的中位数为:" + sktwo2);
//        System.out.println("园艺植物设施栽培学的中位数为:" +sktwo3);




    }
}
